home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Jotto ][ 1.2 / source / Wipes ƒ / Circle out.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.5 KB  |  56 lines  |  [TEXT/MMCC]

  1. #include "timing.h"
  2.  
  3. #define    gap            4        /* difference between one radius and the next */
  4. #define CorrectTime 2
  5. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  6. #define theWindowWidth (boundsRect.right-boundsRect.left)
  7.  
  8. pascal short CircleOut(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  9.  
  10. /* Make a circular region and use it as the mask in CopyBits.  Lots of overlap,
  11.    but masked by timing correction.  If you want to optimize it, look at the
  12.    donut region code in "Circle in.c" */
  13.    
  14. pascal short CircleOut(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  15. {
  16.     Rect            theRect;
  17.     short            cx, cy;
  18.     RgnHandle        curregion;
  19.     Point            zeroPoint;
  20.     
  21.     zeroPoint.h=boundsRect.left;
  22.     zeroPoint.v=boundsRect.top;
  23.     
  24.     cx = theWindowWidth / 2;
  25.     cy = theWindowHeight / 2;
  26.     
  27.     theRect.left=cx-gap;         /* circumscribing rectangle for circle */
  28.     theRect.right=cx+gap;
  29.     theRect.top=cy-gap;
  30.     theRect.bottom=cy+gap;
  31.     OffsetRect(&theRect, boundsRect.left, boundsRect.top);
  32.     
  33.     curregion=NewRgn();
  34.     
  35.     do
  36.     {
  37.         StartTiming();
  38.         SetEmptyRgn(curregion);
  39.         OpenRgn();
  40.             FrameOval(&theRect);   /* the circle region */
  41.         CloseRgn(curregion);
  42.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  43.                 &boundsRect, &boundsRect, 0, curregion);
  44.         theRect.left-=gap;        /* make the rect bigger (and thus the circle) */
  45.         theRect.right+=gap;
  46.         theRect.top-=gap;
  47.         theRect.bottom+=gap;
  48.         TimeCorrection(CorrectTime);
  49.     }
  50.     while (!PtInRgn(zeroPoint, curregion));
  51.     
  52.     DisposeRgn(curregion);
  53.     
  54.     return 0;
  55. }
  56.